<template>
  <!--我的钱包-->
  <div id="app" class="backf4">
      <loading v-if="loading"></loading>
      <!--我的钱包-->
      <div class="my-withdraw">
          <mt-swipe :show-indicators="false" :auto="0" :continuous="false" style="height: 11.34rem;" @change="handleChange">
            <mt-swipe-item>
                <!--滑动盒子1111-->
                <div class="my-swiper my-with1">
                    <!--宝宝账户-->
                    <div class="my-card my-card1">
                        <div class="my-top">
                            <div class="item1">宝宝账户(￥)</div>
                            <div class="item2">
                                <a class="wa-block-link" href="/views/bindalipay/index.html?&h5=true" style="display: inline-block;">
                                    绑定支付宝
                                </a>
                            </div>
                        </div>
                        <p class="my-money"  v-text="mymoney.money || 0">200000.00</p>
                        <div class="my-daylist">
                            <div class="item1">
                                <p>最近30天收支</p>
                                <p class="my-money2" v-text="mymoney.three_total || 0">-200000.00</p>
                            </div>
                            <div class="item2">
                                <p>今日收支</p>
                                <p class="my-money2" v-text="mymoney.current_total || 0">+200000.00</p>
                            </div>
                        </div>
                        <div class="padd-card1"></div>
                    </div>
                    <!--查看明细-->
                    <a class="wa-block-link" href="/views/changetime/index.html?moneytype=1&h5=true">
                        <div class="my-looklist my-looklist1">
                            <div class="item1">查看明细</div>
                            <div class="item2">
                                <span class="polh-icon">近期消费情况<span class="icon-red"></span></span>                                
                            </div>
                        </div>
                    </a>
                    <!--已经绑定支付宝-->
                    <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=1&way=1&h5=true" v-if="audit == 2">
                      <div class="my-looklist">
                              <div class="item1">提现</div>
                              <div class="item2">
                                  <span class="polh-icon">可直接转账到支付宝</span>                            
                              </div>
                      </div>
                    </a>
                    <!--支付宝没绑定好的情况-->
                    <div class="my-looklist" v-if="audit != 2" @click="noaliMessage">
                            <div class="item1">提现</div>
                            <div class="item2">
                                <span class="polh-icon">可直接转账到支付宝</span>                            
                            </div>
                    </div>
                    <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=1&way=2&h5=true">
                      <div class="my-looklist">
                          <div class="item1">转为音符</div>
                          <div class="item2">
                              <span class="polh-icon">转成音符后可直接消费</span>                            
                          </div>
                      </div>
                    </a>                   
                </div>
            </mt-swipe-item>
            <mt-swipe-item>
                <!--滑动盒子-->
                <div class="my-swiper my-with2">
                    <!--宝宝账户-->
                    <div class="my-card my-card2">
                        <div class="my-top">
                            <div class="item1">我的音符<span></span></div>
                            <div class="item2">
                                <a class="wa-block-link" href="/views/bindalipay/index.html?h5=true">
                                    绑定支付宝
                                </a>
                            </div>
                        </div>
                        <p class="my-money" v-text="mydaimd.diamonds || 0">2000.00</p>
                        <div class="my-daylist">
                            <div class="item1">
                                <p>最近30天充值</p>
                                <p class="my-money2" v-text="mydaimd.three_charge || 0">200000.00</p>
                            </div>
                            <div class="item2">
                                <p>最近30天消费</p>
                                <p class="my-money2" v-text="mydaimd.three_expend || 0">200000.00</p>
                            </div>
                        </div>
                        <div class="padd-card2 padd-card2-left"></div>
                        <div class="padd-card2 padd-card2-right"></div>                        
                    </div>
                    <!--查看明细-->
                    <a class="wa-block-link" href="/views/changetime/index.html?moneytype=2&h5=true">
                        <div class="my-looklist my-looklist1">
                            <div class="item1">查看明细</div>
                            <div class="item2">
                                <span class="polh-icon">近期消费情况<span class="icon-red"></span></span>
                                
                            </div>
                        </div>
                    </a>
                </div>            
            </mt-swipe-item>
            <mt-swipe-item> 
                <!--滑动盒子-->
                <div class="my-swiper my-with3">
                    <!--宝宝账户-->
                    <div class="my-card my-card3">
                        <div class="my-top">
                            <div class="item1">我的声贝</div>
                            <div class="item2">
                                <a class="wa-block-link" href="/views/bindalipay/index.html?h5=true">
                                    绑定支付宝
                                </a>
                            </div>
                        </div>
                        <p class="my-money" v-text="mycham.charm || 0">200000.00</p>
                        <div class="my-daylist">
                            <div class="item1">
                                <p>最近30天收入</p>
                                <p class="my-money2" v-text="mycham.three_total || 0">-200000.00</p>
                            </div>
                            <div class="item2">
                                <p>今日收入</p>
                                <p class="my-money2" v-text="mycham.current_total || 0">+200000.00</p>
                            </div>
                        </div>
                        <div class="padd-card3"></div>
                    </div>
                    <!--查看明细-->
                    <a class="wa-block-link" href="/views/changetime/index.html?moneytype=3&h5=true">
                        <div class="my-looklist my-looklist1">
                            <div class="item1">查看明细</div>
                            <div class="item2">
                                <span class="polh-icon">近期消费情况<span class="icon-red"></span></span>
                            </div>
                        </div>
                    </a>
                    <!--提现有支付宝的时候-->
                    <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=3&way=1&h5=true" v-if="audit == 2" @click="noaliMessage">
                        <div class="my-looklist">
                            <div class="item1">提现</div>
                            <div class="item2">
                                <span class="polh-icon">可直接转账到支付宝</span>                            
                            </div>
                        </div>
                    </a>
                    <!--没支付宝的时候-->
                    <div class="my-looklist" v-if="audit != 2" @click="noaliMessage">
                        <div class="item1">提现</div>
                        <div class="item2">
                            <span class="polh-icon">可直接转账到支付宝</span>                            
                        </div>
                    </div>
                    <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=3&way=2&h5=true">                    
                        <div class="my-looklist">
                            <div class="item1">转为音符</div>
                            <div class="item2">
                                <span class="polh-icon">转换音符后可直接消费</span>                            
                            </div>
                        </div>
                    </a>
                </div>            
            </mt-swipe-item>
          </mt-swipe>
          <!--充值按钮  type 1,账户，2-钻石，3-魅力值   way=,1-提现，2=转钻石，3-充值-->
          <div class="my-btn" v-show="swperIndex == 0">
             <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=1&way=3&h5=true">充值</a>
          </div>          
          <!--钻石充值按钮-->
          <div class="my-btn" style="color: #fff;" v-show="swperIndex == 1">
              <a class="wa-block-link" href="/views/withdrawdpt/index.html?moneytype=2&way=3&h5=true">
                 充值
              </a>
          </div>
      </div>
  </div>
</template>
<script>
    import 'assets/css/common.css'
    import './index.css'
    import common from 'assets/js/common'
    import { Cell } from 'mint-ui'
    import { Swipe, SwipeItem } from 'mint-ui'
    import Loading from "components/loading.vue"
    export default {
      data() {
        return {
          loading:true,
          webname:5464,
          mymoney:'',
          mydaimd:'',
          mycham:'',
          swperIndex:0,
          mymoneyInfo:'',
          audit:'',
          isBandpay:true
        }
      },
      //实例初始化最之前，无法获取到data里的数据
      beforeCreate(){
        
        
      },  
      //在挂载开始之前被调用
      beforeMount(){
        
      
      }, 
      components:{Cell,Swipe,SwipeItem,Loading},
      //已成功挂载，相当ready()
      mounted(){
          this.swperIndex = 0;
          this.getwithdrawInfo();

          //没资质审核跳资质审核页面
          window['goExam'] = function(){
              if(common.platform == 'ios'){               
                 goexamine();
              }
              if(common.platform == 'android'){
                  window.user.goexamine();
              }               
          }

      },
      
      //相关操作事件
      methods: {
          //跳资质审核
          goExam(){
              window.goExam();
          },
          //获取钱
          getUserCharm(type){
                common.ajax({
                    type:'GET',
                    url:'/api/user/charminfo?type='+type
                }).then(res=>{
                     this.loading = false;
                    localStorage.mobile = res.data.mobile;

                    if(type == 2){
                        this.mymoney = res.data;
                    }
                    if(type == 3){
                        this.mydaimd =res.data;
                    }
                    if(type == 1){
                        this.mycham =  res.data;
                    }
                })
          }, 
          //滑动显示填充块
          handleChange(index){
              this.swperIndex = index;
          },
          //支付宝绑定情况
          getwithdrawInfo:function(){
              common.ajax({
                  type:'get',
                  url:'api/user/withdrawaldata?currency=money'
              }).then(res=>{
                  if(res.data.account || res.data.account != ""){
                    this.isBandpay = true;
                  }else{
                    this.isBandpay = false;                    
                  }
                  //支付宝绑定情况
                  this.audit = res.data.audit;
                  this.getUserCharm(1);
                  this.getUserCharm(2);
                  this.getUserCharm(3);                  
              })
          },
          noaliMessage(){
              var _this = this;
              console.log(this.isBandpay);
              if(!this.isBandpay){

                  common.errMessage('请先绑定支付宝');
                  setTimeout(function(){
                      window.location.href = '/views/bindalipay/index.html?h5=true';
                  },1500)

              }else{
                  if(this.audit == 0){
                      common.errMessage('请先提交身份资料,完成支付宝资质审核');

                      setTimeout(function(){
                          _this.goExam();
                      },1500)
                  }
                  if(this.audit == 1){
                      common.errMessage('支付宝资质审核中');
                  }
                  if(this.audit == 3){

                      common.errMessage('支付宝资质审核失败,请重新提交');
                      setTimeout(function(){
                          _this.goExam();
                      },1500)                      
                  }
              }
          }                            
      }
    }
</script>

